<form action="{:U('weibo/Operate/transpond')}" method="post" id="transpondForm">
<php>if($data['transpond_id']){</php>
	<input type="hidden" name="transpond_id" value="{$data.transpond_id}" />
<php>}else{</php>
	<input type="hidden" name="transpond_id" value="{$data.weibo_id}" />
<php>}</php>
<div style="width:350px; text-align:left">
<php>if($data['transpond_id']){</php>
	<div style="padding:20px 10px 0 10px;">转:{$data.transponInfo.content}</div>
<php>}else{</php>
	<div style="padding:20px 10px 0 10px;">转:{$data.content}</div>
<php>}</php>
<div  style="padding:10px">
<span class="right" id="transpond_count" style="color:#008800">还可以输入131个汉字</span>
</div>

<div style="padding:0 10px">
<textarea id="transpond_content_{$data.weibo_id}" name="content" style="font-family: Tahoma,宋体; overflow: hidden; border: 1px solid #ccc; background-color:#F8F8F8; word-wrap: break-word; font-size: 12px; line-height: 18px; height: 65px; width:328px;" onkeypress="checkTranspondLength(this,140)"  onkeyup="checkTranspondLength(this,140)" onkeydown="checkTranspondLength(this,140)">
<php>if($data['transponInfo']){</php>
//@{$data.uid|getUserName}:{$data.content}
<php>}</php>
</textarea>
</div>

<div style="padding:10px 10px 20px 10px">
	<p style="margin:0;"><input type="checkbox" class="labelbox" name="reply_weibo_id[]" value="{$data.weibo_id}"> 同时作为给 {$data.uid|getUserName} 的评论发布</p>
	<php>if( $data['transpond_id'] && $data['transponInfo']['uid']!=$data['uid'] ){</php>
		<p style="margin:0;"><input type="checkbox" class="labelbox" name="reply_weibo_id[]" value="{$data.transponInfo.weibo_id}"> 同时作为给 {$data.transponInfo.uid|getUserName} 的评论发布</p>
	<php>}</php>
</div>
<div class="answers"><input type="button" onclick="dotranspond()" id="transpond_button" class="btn_b" value="OK"></div>
</div>
</form>

<script>
var content_handle = "transpond_content_{$data.weibo_id}";
var content_jquery_handle = $('#'+content_handle);

var default_transpond_string = "转发微博";
content_jquery_handle.focus(function(){
    if(content_jquery_handle.val() == default_transpond_string) {
        content_jquery_handle.val('');
        checkTranspondLength(content_jquery_handle,140);
    }
}).blur(function(){
    if(content_jquery_handle.val() == '') {
        content_jquery_handle.val(default_transpond_string);
        checkTranspondLength(content_jquery_handle,140);
    }
});

$(document).ready(function(){
	checkTranspondLength(content_jquery_handle,140);
	
	if (content_jquery_handle.val() == '') {
		content_jquery_handle.val(default_transpond_string);
        checkTranspondLength(content_jquery_handle,140);
	}else {
		var textArea = document.getElementById('transpond_content_{$data.weibo_id}');
	    if (document.selection) { //IE
	         var rng = textArea.createTextRange();
	         rng.collapse(true);
	         rng.moveStart("character",0)
	    }else if (textArea.selectionStart || (textArea.selectionStart == '0')) { // Mozilla/Netscape…
	        textArea.selectionStart = 0;
	        textArea.selectionEnd = 0;
	    }
		textArea.focus();
	}
	
	
	shortcut('ctrl+return',	function(){dotranspond();},{'target':content_handle});
});

//检测输入字符数
function checkTranspondLength(obj,num){
	var str = $(obj).val();  
	var len = str.length;
	if(len==0){
		$('#transpond_button').attr('disabled',true);
		$('#transpond_button').attr('class','btn_b_disable');
		$('#transpond_count').html('你还可以输入'+ (num-len) + '字');
	}else if( len > num ){
		$('#transpond_button').attr('disabled',true);
		$('#transpond_button').attr('class','btn_b_disable');
		$('#transpond_count').css('color','red');
		$('#transpond_count').html('已超出'+ (len-num) +'字');
		//textareaStatus('off');
	}else if( len <= num ){
		$('#transpond_button').removeAttr('disabled');
		$('#transpond_button').attr('class','btn_b');
		$('#transpond_count').css('color','#008800');
		$('#transpond_count').html('你还可以输入'+ (num-len) + '字');
	}
}
	
	function dotranspond(o){
		var options = {
			success:function(txt){
				if( txt ){
					<php>if($data['upcontent']){</php>
						$(".feed_list").prepend( txt ).slideDown('slow');
					<php>}</php>
					weibo.upCount('weibo');
				}else{
					alert('转发失败');
				}
			  ui.box.close();
			}
		};
		$('#transpond_button').val('转发中...');
		$("#transpondForm").ajaxSubmit( options );
	}
</script>